using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;

public class Ballet : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject ballet;
    Transform ttransform;
    PlayerBasic player;
    float CDtime;
    public float CD;
    public int ballettime;
    void Start()
    {
        ttransform = GetComponent<Transform>();
        player = GetComponentInParent<PlayerBasic>();
        ballettime = PlayerData.balletnum;
        //ballettime = 10;
        CDtime = CD;
    }
    private void Update()
    {
        if (CDtime > 0)
        {
            CDtime -= Time.deltaTime;
        }
        else
        {
            grind1();
            CDtime = CD;
        }
    }
    // Update is called once per frame
    void grind1()
    {
        Quaternion rotation= ttransform.localRotation;
        rotation.z = 0;
        for (int i = 1; i <= ballettime; i++)
        {
            
            
            Instantiate(ballet, transform.position, rotation,transform);
            transform.GetChild(0).GetComponent<Ballent2>().forward = new Vector2(Mathf.Cos( rotation.z*Mathf.Deg2Rad), Mathf.Sin(rotation.z * Mathf.Deg2Rad));
            transform.GetChild(0).parent = null;
            rotation.z += 360f / ballettime;
        }
    }
}
